package main
import "fmt"

func main(){
    /*
	练习2：求两个3*3矩阵的和并输出（数据都是int类型）
			解析：矩阵的和计算规则是对应元素相加：
			c[i][j] = a[i][j] + b[i][j]
	*/
	a := [3][3]int{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9}}
	b := [3][3]int{
		{9, 8, 7},
		{6, 5, 4},
		{3, 2, 1}}

	var c [3][3]int

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			c[i][j] = a[i][j] + b[i][j]
		}
	}

	fmt.Println("矩阵c的和为：")
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Printf("%d ", c[i][j])
		}
		fmt.Println()
	}
}
